home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v17n03 / ucrasm.exe / SOURCE.EXE / PUTI.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-10-12  |  966 b   |  63 lines

  1. StdGrp        group    stdlib,stddata
  2. stddata        segment    para public 'sldata'
  3. stddata        ends
  4. ;
  5. stdlib        segment    para public 'slcode'
  6.         assume    cs:stdgrp
  7.         extrn    sl_putc:far
  8. ;
  9. ; Puti prints the value in AX as a signed integer value.
  10. ;
  11.         public    sl_puti
  12. sl_Puti        proc    far
  13.         push    ax
  14.         push    bx
  15.         push    dx
  16.         cmp    ax, 0
  17.         jge    Doit
  18.         push    ax
  19.         mov    al, '-'
  20.         call    sl_Putc
  21.         pop    ax
  22.         neg    ax
  23. ;
  24. DoIt:        call    puti2
  25.         pop    dx
  26.         pop    bx
  27.         pop    ax
  28.         ret
  29. sl_Puti        endp
  30. ;
  31. ; Putu prints the value in AX as an unsigned integer value.
  32. ;
  33.         public    sl_PutU
  34. sl_PutU        proc    far
  35.         push    ax
  36.         push    bx
  37.         push    dx
  38.         call    PutI2
  39.         pop    dx
  40.         pop    bx
  41.         pop    ax
  42.         ret
  43. sl_PutU        endp
  44. ;
  45. ; PutI2- Recursive routine to actually print the value in AX as an integer.
  46. ;
  47. Puti2        proc    near
  48.         mov    bx, 10
  49.         xor    dx, dx
  50.         div    bx
  51.         or    ax, ax        ;See if ax=0
  52.         jz    Done
  53.         push    dx
  54.         call    Puti2
  55.         pop    dx
  56. Done:        mov    al, dl
  57.         or    al, '0'
  58.         call    sl_Putc
  59.         ret
  60. PutI2        endp
  61. stdlib        ends
  62.         end
  63.